<template>
  <div class="attention_main">
    <div class="mincard mincard_Width">
      <nuxt-link
        v-for="(item, index) in attentionList"
        :key="index"
        :to="item.path"
        :class="currentIndex == index ? 'active' : ''"
      >
        {{ item.content }}
      </nuxt-link>
    </div>
    <div class="attention_warpper">
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </div>
  </div>
</template>

<script>
export default {
  name: "attention",
  data() {
    return {
      currentIndex: "",
      attentionList: [
        { content: "关注的企业", path: "/VIP/attention/enterprise" },
        { content: "订阅的部门", path: "/VIP/attention/department" }
      ]
    };
  },
  watch: {
    // $route: {
    //   deep: true,
    //   immediate: true,
    //   hanld(val) {
    //     let index = this.attentionList.findIndex(el => el.path === val.path);
    //     this.currentIndex = index;
    //     // console.log(index);
    //   }
    // }
  }
};
</script>

<style lang="less" scoped>
.attention_main {
  display: flex;
  flex-direction: column;
  .mincard_Width {
    width: 900px;
    height: 50px;
    background-color: #fff;
    padding: 0 20px;
    a {
      height: 100%;
      display: flex;
      align-items: center;
      margin: 0 20px;
      font-size: 16px;
      color: #000;
      &.router-link-active {
        color: #44a2ff;
        position: relative;
        &::after {
          content: "";
          width: 40px;
          height: 5px;
          background-color: #44a2ff;
          position: absolute;
          bottom: 0;
          left: 50%;
          right: 50%;
          transform: translateX(-50%);
        }
      }
    }
  }
  .attention_warpper {
    margin-top: 10px;
    min-height: 462px;
  }
}
</style>
